//
//  BooksCollectionViewCell.m
//  iOSCodeLearning
//
//  Created by TFAppleWork-Summer on 2018/1/13.
//  Copyright © 2018年 Ace. All rights reserved.
//

#import "BooksCollectionViewCell.h"

@interface BooksCollectionViewCell()

@property (nonatomic, strong) UILabel  *bookName;


@property (nonatomic, strong) UIButton  *button;

@end

@implementation BooksCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = [UIColor orangeColor];
        [self.contentView addSubview:self.bookName];
    }
    return self;
}

- (void)layoutSubviews{
    
    [super layoutSubviews];
    
    self.bookName.frame = CGRectMake(0, 0, 0, 0);
     [self.bookName sizeToFit];
    
}


- (void)updateBookName:(NSString *)bookName{
    self.bookName.text = bookName;
}

#pragma mark - action
-(void)btnClick:(UIButton *)btn{
    
    
}


-(UILabel*)bookName{
    if (!_bookName) {
        _bookName = [[UILabel alloc] init];
    }
    return _bookName;
}

-(UIButton*)button{
    if (!_button) {
        _button = [[UIButton alloc] init];
        _button.backgroundColor = [UIColor greenColor];
        [_button addTarget:self action:@selector(btnClick:) forControlEvents: UIControlEventTouchUpInside];
    }
    return _button;
}

@end
